package com.chainyoung.component_tmtrade.ui.adapter;

import android.content.Context;
import android.graphics.Color;
import android.support.annotation.Nullable;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chainyoung.common.utils.ConvertUtils;
import com.chainyoung.component_tmtrade.R;

import java.util.List;

public class SelectOrderStatusAdapter extends BaseQuickAdapter<String,BaseViewHolder> {

    private View.OnClickListener onClickListener;
    private Context context;

    private int selectIndex=0;
    private int left,right;

    public SelectOrderStatusAdapter(Context context,@Nullable List<String> data) {
        super(R.layout.list_order_status_item, data);
        this.context=context;
         left= ConvertUtils.dp2px(context,30);
         right=ConvertUtils.dp2px(context,20);
    }



    @Override
    protected void convert(BaseViewHolder helper, String item) {
        helper.setText(R.id.tv_status_name,item);
        helper.getView(R.id.rl).setOnClickListener(onClickListener);
        helper.getView(R.id.rl).setTag(helper.getAdapterPosition());
        helper.setTextColor(R.id.tv_status_name,helper.getAdapterPosition()==selectIndex? Color.parseColor("#6866f7"):Color.parseColor("#7D8DA6"));
        helper.getView(R.id.iv_select).setVisibility(helper.getAdapterPosition()==selectIndex?View.VISIBLE:View.GONE);
        helper.getView(R.id.rl).setPadding(left,0,right,0);
    }

    public void setOnClickListener(View.OnClickListener onClickListener) {
        this.onClickListener = onClickListener;
    }

    public void setSelectIndex(int selectIndex) {
        this.selectIndex = selectIndex;
    }
}
